import type {
  Address,
  COrderListData,
  ExpressData,
  MedicalOrderDetail,
  OrderListData,
  OrderPre,
  OrderQuery,
} from '@/types/order'
import request from '@/utils/request'

export const addressListApi = () => {
  return request.get<null, Address[]>('/patient/order/address')
}

export const preOrderApi = (prescriptionId: string) => {
  return request.get<null, OrderPre>('/patient/medicine/order/pre', { params: { prescriptionId } })
}

export const createOrderApi = (id: string, addressId: string) => {
  return request.post<any, { id: string }>('/patient/medicine/order', { id, addressId })
}

export const getMedicalOrderDetail = (id: string) => {
  return request.get<any, MedicalOrderDetail>(`/patient/medicine/order/detail/${id}`)
}

export const orderListApi = (status = 10, current = 1, pageSize = 10) => {
  return request.get<null, OrderListData>('/patient/medicine/order/mylist', {
    params: { status, current, pageSize },
  })
}

export const getConsultOrderListApi = (data: OrderQuery) => {
  return request.get<null, COrderListData>('/patient/consult/order/list', { params: data })
}

// 获取药品订单物流信息
export const getMedicalOrderLogistics = (id: string) => {
  return request.get<null, ExpressData>(`/patient/order/${id}/logistics`)
}
